/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PanelPrincipal.java
 *
 * Created on Dec 6, 2011, 6:13:02 PM
 */
package ar.com.wholeconsulting.pacc.gui;

import ar.com.wholeconsulting.pacc.gui.aceros.FrameAceros;
import ar.com.wholeconsulting.pacc.gui.aparatos.FrameAparato;
import ar.com.wholeconsulting.pacc.gui.fluidos.FrameFluidos;
import ar.com.wholeconsulting.pacc.gui.modelos.FrameModelo;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.PACCAbstractTreeTableModel;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.TreeTableNode;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.aparatos.AparatosTreeTableModel;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.aparatos.AparatosTreeTableNode;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.modelos.ModelosTreeTableModel;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.modelos.ModelosTreeTableNode;
import ar.com.wholeconsulting.pacc.gui.utils.treetable.modelos.ModelosTreeTableSelectionListener;
import ar.com.wholeconsulting.pacc.model.Aparato;
import ar.com.wholeconsulting.pacc.model.Fabricante;
import ar.com.wholeconsulting.pacc.model.Modelo;
import ar.com.wholeconsulting.pacc.model.Usuario;
import ar.com.wholeconsulting.pacc.persistance.JPASession;
import java.awt.Window;
import java.util.List;
import javax.swing.DefaultListModel;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.tree.TreeSelectionModel;
import org.jdesktop.swingx.JXList;

/**
 *
 * @author pable
 */
public class PanelPrincipal extends javax.swing.JFrame {

    /**
     * Creates new form PanelPrincipal
     */
    public PanelPrincipal() {
        initComponents();
        initComponentsView();
    }

    /**
     * This method is called from within the constructor to initialize the form. WARNING: Do NOT modify this code. The content of this method is always regenerated by the Form Editor.
     */
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        toolBar = new javax.swing.JToolBar();
        editFluidos = new javax.swing.JButton();
        editMetales = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        panelModelos = new javax.swing.JPanel();
        jScrollPane2 = new javax.swing.JScrollPane();
        modeloTreeTrable = new org.jdesktop.swingx.JXTreeTable(new ModelosTreeTableModel());
        addModelo = new javax.swing.JButton();
        editModelo = new javax.swing.JButton();
        deleteModelo = new javax.swing.JButton();
        refreshModelo = new javax.swing.JButton();
        panelAparatos = new javax.swing.JPanel();
        jScrollPane1 = new javax.swing.JScrollPane();
        apartosTreeTable = new org.jdesktop.swingx.JXTreeTable(new AparatosTreeTableModel());
        addAparato = new javax.swing.JButton();
        editAparato = new javax.swing.JButton();
        deleteAparato = new javax.swing.JButton();
        refreshAparato = new javax.swing.JButton();
        panelFabricante = new javax.swing.JPanel();
        addFabricante = new javax.swing.JButton();
        editFabricante = new javax.swing.JButton();
        deleteFabricante = new javax.swing.JButton();
        refreshFabricante = new javax.swing.JButton();
        jScrollPane3 = new javax.swing.JScrollPane();
        listFabricantes = new JXList();
        panelUsuario = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        listUsuarios = new JXList();
        addUsuario = new javax.swing.JButton();
        editUsuario = new javax.swing.JButton();
        deleteUsuario = new javax.swing.JButton();
        refreshUsuario = new javax.swing.JButton();
        menuPrincipal = new javax.swing.JMenuBar();
        menuArchivo = new javax.swing.JMenu();
        menuDocumentacion = new javax.swing.JMenu();
        menuAparatosSinFuego = new javax.swing.JMenu();
        menuCalderas = new javax.swing.JMenu();
        menuAuditorias = new javax.swing.JMenu();
        menuElementosDeSeguridad = new javax.swing.JMenu();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Aparatos a Presion");

        toolBar.setRollover(true);

        editFluidos.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/research_16x16.gif"))); // NOI18N
        editFluidos.setToolTipText("Editor de Fluidos");
        editFluidos.setFocusable(false);
        editFluidos.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editFluidos.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editFluidos.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editFluidosActionPerformed(evt);
            }
        });
        toolBar.add(editFluidos);

        editMetales.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/law_16x16.gif"))); // NOI18N
        editMetales.setToolTipText("Editor de Metales");
        editMetales.setFocusable(false);
        editMetales.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        editMetales.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        editMetales.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editMetalesActionPerformed(evt);
            }
        });
        toolBar.add(editMetales);
        toolBar.add(jSeparator2);

        modeloTreeTrable.setClosedIcon(new javax.swing.ImageIcon(getClass().getResource("/16x16/factory.png")));
        modeloTreeTrable.setLeafIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_16x16.gif")));
        modeloTreeTrable.setOpenIcon(new javax.swing.ImageIcon(getClass().getResource("/16x16/factory.png")));
        modeloTreeTrable.getTableHeader().setReorderingAllowed(false);
        jScrollPane2.setViewportView(modeloTreeTrable);

        addModelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(add)_16x16.gif"))); // NOI18N
        addModelo.setToolTipText("Agregar Modelo");
        addModelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addModeloActionPerformed(evt);
            }
        });

        editModelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(edit)_16x16.gif"))); // NOI18N
        editModelo.setToolTipText("Editar Modelo");
        editModelo.setEnabled(false);
        editModelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editModeloActionPerformed(evt);
            }
        });

        deleteModelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(delete)_16x16.gif"))); // NOI18N
        deleteModelo.setToolTipText("Eliminar Modelo");
        deleteModelo.setEnabled(false);

        refreshModelo.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/refresh_16x16.gif"))); // NOI18N
        refreshModelo.setToolTipText("Actualizar Modelos");
        refreshModelo.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshModeloActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelModelosLayout = new javax.swing.GroupLayout(panelModelos);
        panelModelos.setLayout(panelModelosLayout);
        panelModelosLayout.setHorizontalGroup(
            panelModelosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelModelosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelModelosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE)
                    .addGroup(panelModelosLayout.createSequentialGroup()
                        .addComponent(addModelo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editModelo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteModelo)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(refreshModelo)))
                .addContainerGap())
        );
        panelModelosLayout.setVerticalGroup(
            panelModelosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelModelosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelModelosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelModelosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(addModelo)
                        .addComponent(editModelo)
                        .addComponent(deleteModelo))
                    .addComponent(refreshModelo))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane2, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Modelos", panelModelos);

        apartosTreeTable.getTableHeader().setReorderingAllowed(false);
        jScrollPane1.setViewportView(apartosTreeTable);

        addAparato.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(add)_16x16.gif"))); // NOI18N
        addAparato.setToolTipText("Agregar Aparato");
        addAparato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                addAparatoActionPerformed(evt);
            }
        });

        editAparato.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(edit)_16x16.gif"))); // NOI18N
        editAparato.setToolTipText("Editar Aparato");
        editAparato.setEnabled(false);
        editAparato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                editAparatoActionPerformed(evt);
            }
        });

        deleteAparato.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/database_(delete)_16x16.gif"))); // NOI18N
        deleteAparato.setToolTipText("Eliminar Aparato");
        deleteAparato.setEnabled(false);

        refreshAparato.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/refresh_16x16.gif"))); // NOI18N
        refreshAparato.setToolTipText("Actualizar Aparatos");
        refreshAparato.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshAparatoActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelAparatosLayout = new javax.swing.GroupLayout(panelAparatos);
        panelAparatos.setLayout(panelAparatosLayout);
        panelAparatosLayout.setHorizontalGroup(
            panelAparatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAparatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAparatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE)
                    .addGroup(panelAparatosLayout.createSequentialGroup()
                        .addComponent(addAparato)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editAparato)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteAparato)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(refreshAparato)))
                .addContainerGap())
        );
        panelAparatosLayout.setVerticalGroup(
            panelAparatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelAparatosLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelAparatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(panelAparatosLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(addAparato)
                        .addComponent(editAparato)
                        .addComponent(deleteAparato))
                    .addComponent(refreshAparato))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Aparatos", panelAparatos);

        addFabricante.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/record_(add)_16x16.gif"))); // NOI18N
        addFabricante.setToolTipText("Agregar Fabricante");
        addFabricante.setEnabled(false);

        editFabricante.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/record_(edit)_16x16.gif"))); // NOI18N
        editFabricante.setToolTipText("Editar Fabricante");
        editFabricante.setEnabled(false);

        deleteFabricante.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/record_(delete)_16x16.gif"))); // NOI18N
        deleteFabricante.setToolTipText("Eliminar Fabricante");
        deleteFabricante.setEnabled(false);

        refreshFabricante.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/refresh_16x16.gif"))); // NOI18N
        refreshFabricante.setToolTipText("Actualizar Fabricantes");
        refreshFabricante.setFocusable(false);
        refreshFabricante.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        refreshFabricante.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        refreshFabricante.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshFabricanteActionPerformed(evt);
            }
        });

        listFabricantes.setModel(new DefaultListModel());
        jScrollPane3.setViewportView(listFabricantes);

        javax.swing.GroupLayout panelFabricanteLayout = new javax.swing.GroupLayout(panelFabricante);
        panelFabricante.setLayout(panelFabricanteLayout);
        panelFabricanteLayout.setHorizontalGroup(
            panelFabricanteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFabricanteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelFabricanteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE)
                    .addGroup(panelFabricanteLayout.createSequentialGroup()
                        .addComponent(addFabricante)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editFabricante)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteFabricante)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(refreshFabricante)))
                .addContainerGap())
        );
        panelFabricanteLayout.setVerticalGroup(
            panelFabricanteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelFabricanteLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelFabricanteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelFabricanteLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(addFabricante)
                        .addComponent(editFabricante)
                        .addComponent(deleteFabricante))
                    .addComponent(refreshFabricante))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Farbicantes", panelFabricante);

        listUsuarios.setModel(new DefaultListModel());
        jScrollPane4.setViewportView(listUsuarios);

        addUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/user8_(add)_16x16.gif"))); // NOI18N
        addUsuario.setToolTipText("Agregar Usuario");
        addUsuario.setEnabled(false);

        editUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/user8_(edit)_16x16.gif"))); // NOI18N
        editUsuario.setToolTipText("Editar Usuario");
        editUsuario.setEnabled(false);

        deleteUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/user8_(delete)_16x16.gif"))); // NOI18N
        deleteUsuario.setToolTipText("Eliminar Usuario");
        deleteUsuario.setEnabled(false);

        refreshUsuario.setIcon(new javax.swing.ImageIcon(getClass().getResource("/aspneticons_v1.0_Nov2006/refresh_16x16.gif"))); // NOI18N
        refreshUsuario.setToolTipText("Actualizar Usuarios");
        refreshUsuario.setFocusable(false);
        refreshUsuario.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        refreshUsuario.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        refreshUsuario.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                refreshUsuarioActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout panelUsuarioLayout = new javax.swing.GroupLayout(panelUsuario);
        panelUsuario.setLayout(panelUsuarioLayout);
        panelUsuarioLayout.setHorizontalGroup(
            panelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUsuarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 507, Short.MAX_VALUE)
                    .addGroup(panelUsuarioLayout.createSequentialGroup()
                        .addComponent(addUsuario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(editUsuario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(deleteUsuario)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(refreshUsuario)))
                .addContainerGap())
        );
        panelUsuarioLayout.setVerticalGroup(
            panelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(panelUsuarioLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(panelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(panelUsuarioLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                        .addComponent(addUsuario)
                        .addComponent(editUsuario)
                        .addComponent(deleteUsuario))
                    .addComponent(refreshUsuario))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 474, Short.MAX_VALUE)
                .addContainerGap())
        );

        jTabbedPane1.addTab("Usuarios", panelUsuario);

        menuArchivo.setText("File");
        menuPrincipal.add(menuArchivo);

        menuDocumentacion.setText("Edit");
        menuPrincipal.add(menuDocumentacion);

        menuAparatosSinFuego.setText("Aparatos sin Fuego");
        menuPrincipal.add(menuAparatosSinFuego);

        menuCalderas.setText("Calderas");
        menuPrincipal.add(menuCalderas);

        menuAuditorias.setText("Auditorias");
        menuPrincipal.add(menuAuditorias);

        menuElementosDeSeguridad.setText("Elementos de Seguridad");
        menuPrincipal.add(menuElementosDeSeguridad);

        setJMenuBar(menuPrincipal);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jTabbedPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE)
                .addGap(12, 12, 12))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTabbedPane1)
                .addContainerGap())
        );

        java.awt.Dimension screenSize = java.awt.Toolkit.getDefaultToolkit().getScreenSize();
        setBounds((screenSize.width-560)/2, (screenSize.height-661)/2, 560, 661);
    }// </editor-fold>//GEN-END:initComponents

    private void editFluidosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editFluidosActionPerformed
        Window frame = new FrameFluidos(this);
        frame.setVisible(true);
    }//GEN-LAST:event_editFluidosActionPerformed

    private void editMetalesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editMetalesActionPerformed
        Window frame = new FrameAceros(this);
        frame.setVisible(true);
    }//GEN-LAST:event_editMetalesActionPerformed

    private void refreshModeloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshModeloActionPerformed
        ((PACCAbstractTreeTableModel) modeloTreeTrable.getTreeTableModel()).emptyModel();
        List<Object> list = JPASession.getInstance().getResultListNamedQuery(Fabricante.FIND_ALL);
        for (Object fabricante : list) {
            if (((Fabricante) fabricante).getModelos().size() > 0) {
                ((PACCAbstractTreeTableModel) modeloTreeTrable.getTreeTableModel()).addToRoot(new ModelosTreeTableNode((Fabricante) fabricante));
            }
        }
        modeloTreeTrable.updateUI();
    }//GEN-LAST:event_refreshModeloActionPerformed

    private void editModeloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editModeloActionPerformed
        TreeTableNode node = (TreeTableNode) modeloTreeTrable.getTreeSelectionModel().getSelectionPath().getLastPathComponent();
        Window frame = new FrameModelo(this, (Modelo) node.getObj());
        frame.setVisible(true);
    }//GEN-LAST:event_editModeloActionPerformed

    private void refreshAparatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshAparatoActionPerformed
        ((PACCAbstractTreeTableModel) apartosTreeTable.getTreeTableModel()).emptyModel();
        List<Object> list = JPASession.getInstance().getResultListNamedQuery(Usuario.FIND_ALL);
        for (Object usr : list) {
            if (((Usuario) usr).getAparatos().size() > 0) {
                ((PACCAbstractTreeTableModel) modeloTreeTrable.getTreeTableModel()).addToRoot(new AparatosTreeTableNode((Usuario) usr));
            }
        }
        apartosTreeTable.updateUI();
    }//GEN-LAST:event_refreshAparatoActionPerformed

    private void addModeloActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addModeloActionPerformed
        Window frame = new FrameModelo(this);
        frame.setVisible(true);
    }//GEN-LAST:event_addModeloActionPerformed

    private void addAparatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_addAparatoActionPerformed
        JDialog frame = new FrameAparato(this);
        frame.setVisible(true);
    }//GEN-LAST:event_addAparatoActionPerformed

    private void refreshFabricanteActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshFabricanteActionPerformed
        List<Object> list = JPASession.getInstance().getResultListNamedQuery(Fabricante.FIND_ALL);
        for (Object usr : list) {
            ((DefaultListModel) listFabricantes.getModel()).addElement(usr);
        }
        listFabricantes.updateUI();
    }//GEN-LAST:event_refreshFabricanteActionPerformed

    private void refreshUsuarioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_refreshUsuarioActionPerformed
        List<Object> list = JPASession.getInstance().getResultListNamedQuery(Usuario.FIND_ALL);
        for (Object usr : list) {
            ((DefaultListModel) listUsuarios.getModel()).addElement(usr);
        }
        listUsuarios.updateUI();
    }//GEN-LAST:event_refreshUsuarioActionPerformed

    private void editAparatoActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_editAparatoActionPerformed
        TreeTableNode node = (TreeTableNode) apartosTreeTable.getTreeSelectionModel().getSelectionPath().getLastPathComponent();
        JDialog frame = new FrameAparato(this, (Aparato) node.getObj());
        frame.setVisible(true);
    }//GEN-LAST:event_editAparatoActionPerformed

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {

            @Override
            public void run() {
                new PanelPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton addAparato;
    private javax.swing.JButton addFabricante;
    private javax.swing.JButton addModelo;
    private javax.swing.JButton addUsuario;
    private org.jdesktop.swingx.JXTreeTable apartosTreeTable;
    private javax.swing.JButton deleteAparato;
    private javax.swing.JButton deleteFabricante;
    private javax.swing.JButton deleteModelo;
    private javax.swing.JButton deleteUsuario;
    private javax.swing.JButton editAparato;
    private javax.swing.JButton editFabricante;
    private javax.swing.JButton editFluidos;
    private javax.swing.JButton editMetales;
    private javax.swing.JButton editModelo;
    private javax.swing.JButton editUsuario;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JList listFabricantes;
    private javax.swing.JList listUsuarios;
    private javax.swing.JMenu menuAparatosSinFuego;
    private javax.swing.JMenu menuArchivo;
    private javax.swing.JMenu menuAuditorias;
    private javax.swing.JMenu menuCalderas;
    private javax.swing.JMenu menuDocumentacion;
    private javax.swing.JMenu menuElementosDeSeguridad;
    private javax.swing.JMenuBar menuPrincipal;
    private org.jdesktop.swingx.JXTreeTable modeloTreeTrable;
    private javax.swing.JPanel panelAparatos;
    private javax.swing.JPanel panelFabricante;
    private javax.swing.JPanel panelModelos;
    private javax.swing.JPanel panelUsuario;
    private javax.swing.JButton refreshAparato;
    private javax.swing.JButton refreshFabricante;
    private javax.swing.JButton refreshModelo;
    private javax.swing.JButton refreshUsuario;
    private javax.swing.JToolBar toolBar;
    // End of variables declaration//GEN-END:variables

    private void initComponentsView() {
        modeloTreeTrable.getSelectionModel().setSelectionMode(TreeSelectionModel.SINGLE_TREE_SELECTION);
        modeloTreeTrable.getTreeSelectionModel().addTreeSelectionListener(new ModelosTreeTableSelectionListener(editModelo, deleteModelo));
        refreshAparatoActionPerformed(null);
        refreshFabricanteActionPerformed(null);
        refreshModeloActionPerformed(null);
        refreshUsuarioActionPerformed(null);
    }
}
